﻿using FileConvert.AsposeOper;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace FileConvert.Convert
{
    public class PngConvert : IConvert
    {
        public PngConvert(string fromFile, string toFile)
        {
            _formFile = fromFile;
            _toFile = toFile;
            _ext = System.IO.Path.GetExtension(fromFile);
        }
        private string _formFile = "";
        private string _toFile = "";
        string _ext = "";
        public string SupportFormat
        {
            get
            {
                return ".bmp;.tif;.psd";
            }
        }

        public bool Convert()
        {
            bool result = false;
            try
            { 
                AsposeRegister.Register_Imaging();
                Aspose.Imaging.Image img = Aspose.Imaging.Image.Load(_formFile);
                img.Save(_toFile, new Aspose.Imaging.ImageOptions.PngOptions());
                result = true;
            }
            catch
            {
                result= false;
            } 
            return result;
        }
    }
}
